package com.feihao.zhou.demo01_Thread;

import java.util.ArrayList;
import java.util.function.Consumer;
import java.util.function.Predicate;

public class Test2 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三");
        list.add("ss");
        list.add("aaa");
        list.add("xiexie");
        list.add("张222");
        list.add("张222");

        //
        list.stream().filter(s -> s.startsWith("张")).forEach(s -> System.out.println(s));

        //匿名内部类方法：
        list.stream().filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.startsWith("张");
            }
        }).forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
    }
}
